﻿@model QLMB.ViewModels.InfoFlight

@{
    ViewBag.Title = "GetPlaces";
}

@section script {
    <script src="../../Scripts/jquery.validate.min.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.validate.unobtrusive.min.js" type="text/javascript"></script>
    <script src="../../Scripts/MicrosoftAjax.js" type="text/javascript"></script>
    <script src="../../Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.json-2.2.js" type="text/javascript"></script>
}
<script language = "javascript" type ="text/javascript">
    $(document).ready(function () {
        $("#Sanbaydi").change(function () {
            var idSbdi = $(this).val();
            $.getJSON("/Book/GetListArriveAirport/", { id: idSbdi },
                function (json) {
                    var select = $("#Sanbayden");
                    select.empty();
                    select.attr("data-val", true);
                    select.attr("data-val-required", "Vui long chon san bay den");
                    select.attr("class", "input-validation-error");
                    select.append($('<option/>', {
                        value: 0,
                        text: "Chon diem den"
                    }));
                    $.each(json, function (index, itemData) {
                        select.append($('<option/>', {
                            value: itemData.Value,
                            text: itemData.Text
                        }));
                    });
                });
        });
        $("#Sanbayden").change(function () {
            if ($(this).val() != 0)
                $(this).attr("class", "valid");
            else
                $(this).attr("class", "input-validation-error");
        });

        $("input[name=Loaive]").change(function () {
            if ($(this).val() == "Mot chieu")
                $("#timetoback").hide();
            else
                $("#timetoback").show();
        });

        $("#SoNguoiLon").change(function () {
            var ste = 6 - $(this).val();
            var select = $("#SoTreEm");
            select.empty();
            if (ste < 3) {
                for (i = 0; i <= ste; i++) {
                    select.append($('<option/>', {
                        value: i,
                        text: i
                    }));
                }
            }
            else {
                for (i = 0; i < 3; i++) {
                    select.append($('<option/>', {
                        value: i,
                        text: i
                    }));
                }
            }
        });
    });

</script>

<h2>GetPlaces</h2>
<fieldset>
    <legend>Dat ve may bay</legend>
    <div class = "form">
    @using (Html.BeginForm())
    {
        <table border = 0>
            <tr>
                <td>
                <div class = "editor-label">
                    @Html.LabelFor(x => x.Sanbaydi)
                </div>
                <div class = "editor-field">
                    @Html.DropDownListFor(x => x.Sanbaydi, new SelectList(Model.Sbdi, "Value", "Text"), "Chon diem di")<br />
                    @Html.ValidationMessageFor(x => x.Sanbaydi)
                </div>
                </td>
                <td>
                <div class = "editor-label">
                    @Html.LabelFor(x => x.Sanbayden)
                </div>
                <div class = "editor-field">
                    @Html.DropDownListFor(x => x.Sanbayden, new SelectList(Model.Sbden, "Value", "Text"), "Chon diem den")<br />
                    @Html.ValidationMessageFor(x => x.Sanbayden)
                </div>
                </td>
            </tr>
            <tr>
                <td colspan = "2">
                <div class = "editor-field">
                    @Html.RadioButtonFor(x => x.Loaive,"Mot chieu",true)Mot chieu
                    @Html.RadioButtonFor(x => x.Loaive,"Khu hoi", false)Khu hoi
                    <br />
                    @Html.ValidationMessageFor(x => x.Loaive)
                </div>
                </td>
            </tr>
            <tr>
                <td>
                    Thoi gian di: 
                    <div class = "editor-field" align = "right">@Html.EditorFor(x => x.Ngaydi)
                        @Html.ValidationMessageFor(x => x.Ngaydi)
                    </div>
                </td>
                <td>
                <div id = "timetoback">
                    Thoi gian ve:
                    <div class = "editor-field" align = "right">@Html.EditorFor(x => x.Ngayve)
                        @Html.ValidationMessageFor(x => x.Ngayve)
                    </div>
                </div>
                </td>
            </tr>
            <tr>
                <td>
                    @Html.LabelFor(x => x.SoNguoiLon)
                    @Html.DropDownListFor(x => x.SoNguoiLon, new SelectList(new[]
                                                            {
                                                                new{val = 1, Text = "1"},
                                                                new{val = 2, Text = "2"},
                                                                new{val = 3, Text = "3"},
                                                                new{val = 4, Text = "4"},
                                                                new{val = 5, Text = "5"},
                                                                new{val = 6, Text = "6"},
                                                            }, "val", "Text"))
                </td>
                <td>
                    @Html.LabelFor(x => x.SoTreEm)
                    @Html.DropDownListFor(x => x.SoTreEm, new SelectList(new[]
                                                            {
                                                                new{val = 0, Text = "0"},
                                                                new{val = 1, Text = "1"},
                                                                new{val = 2, Text = "2"},
                                                            },"val","text"))
                </td>
            </tr>
            <tr>
                <td colspan = "2">
                    <div align= "center">
                      <input type="submit" value="Tim kiem" />
                    </div>
			    </td>
            </tr>
        </table>
    }
</div>
</fieldset>

